package cn.yyt.yytravel.inform.controller;


import cn.yyt.yytravel.base.response.JsonResult;
import cn.yyt.yytravel.inform.pojo.dto.InformQuery;
import cn.yyt.yytravel.inform.pojo.dto.InformSaveParam;
import cn.yyt.yytravel.inform.pojo.vo.InformVO;
import cn.yyt.yytravel.inform.service.InformService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("v1/inform")
public class InformController {
    @Autowired
    InformService informService;

    @PostMapping("/add")
    public JsonResult insert(InformSaveParam informSaveParam){
        System.out.println(informSaveParam);
        log.debug("新增申请:informSaveParam={}",informSaveParam);
        informService.insert(informSaveParam);
        return JsonResult.ok();
    }
    @GetMapping("/select")
    public JsonResult select(InformQuery informQuery){
        log.debug("查询，informQuery={}",informQuery);
        List<InformVO> list = informService.select(informQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("/delete/{id}")
    public JsonResult delete(@PathVariable Integer id){
        log.debug("删除，id={}",id);
        informService.delete(id);
        return JsonResult.ok();
    }
}
